﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR50Request", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR50Request))]
    public class RR50RequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR50Request clazz;
        
        public RR50RequestSerializer(IRR50Request clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Kuupaev");
            if (clazz.Kuupaev!=null) {
                Writer.WriteTypeAttribute("http://producers.rr.xtee.riik.ee/producer/rr", "date");
                Writer.WriteString(clazz.Kuupaev.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kuupaev");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Kuupaev") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR50Request>Kuupaev");
                }
                clazz.Kuupaev = new global::Producers.Rr.Xtee.Riik.Ee.Producer.Rr.Date(Reader.ReadElementString("Kuupaev"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR50Request>Kuupaev", Reader.LocalName);
            }
        }
    }
}
